<?php
use com\soka\SokaModel;

class Trabajador_Mdl extends SokaModel
{
	public function get($query){
		$stm = $this->_db->query("SELECT * FROM trabajador WHERE CONCAT(primer_nombre, numero_identidad, primer_apellido) LIKE '%". $query."%' ");
			while($result = $stm->fetch(\PDO::FETCH_OBJ))
				$rows[] = array('value'=> $result->numero_identidad. ',' . $result->primer_nombre . ' ' . $result->primer_apellido
					, 'id'=> $result->id);
			return $rows;
	}
	public function adminis ($_tra,$_admi){
		try {
			$result = $this->_db->prepare("CALL sp_tra_admin('{$_tra}','{$_admi}') ");
	        $result->execute();
	        $response='ok';

	         } catch (\PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
        	die();
        }
        return $response;

}
        public function proyec ($_tra,$_pro){
		try {
			$result = $this->_db->prepare("CALL sp_tra_proy('{$_tra}','{$_pro}') ");
	        $result->execute();
	        $response='ok';

	         } catch (\PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
        	die();
        }
        return $response;
	}
		public function ultimotrabajador(){
		try {
	        $result = $this->_db->prepare("CALL sp_ultimo_trabajador() ");
	        $result->execute();
	        while ($row = $result->fetch(\PDO::FETCH_ASSOC))
				$data[] = $row['id'];
        } catch (\PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
        }
        return $data;
	}
public function ultimocontrato(){
		try {
	        $result = $this->_db->prepare("CALL sp_ultimo_contrato() ");
	        $result->execute();
	        while ($row = $result->fetch(\PDO::FETCH_ASSOC))
				$data[] = $row['id'];
        } catch (\PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
        }
        return $data;
	}

}

